<style>
  .e-dialog1 .el-dialog{
    width:35%;
  }
  .jc{
    font-size: 16px;
    font-weight: bold;
  }
  .el-scrollbar__wrap {
    overflow-x: hidden!important;
  }
</style>
<template>
  <div class="app-container calendar-list-container">

    <div class="filter-container">
      渠道：<el-select style="width:120px" placeholder="请选择渠道" v-model="pageQuery.channelId" clearable >
      <el-option v-for="item in channels"
                 :key="item.channelId"
                 :label="item.channelRemark"
                 :value="item.channelId"/>
    </el-select>
      用户类型：<el-select style="width:120px" placeholder="请选择用户类型" v-model="pageQuery.playerType" clearable >
      <el-option v-for="item in typeOptions"
                 :key="item.value"
                 :label="item.label"
                 :value="item.value"/>
    </el-select>
      状态：<el-select style="width:120px" placeholder="请选择用户状态" v-model="pageQuery.locked" clearable >
      <el-option v-for="item in lockedOptions"
                 :key="item.value"
                 :label="item.label"
                 :value="item.value"/>
    </el-select>
      ID：    <el-input style="width:180px" :maxlength="10" v-model="pageQuery.playerId" placeholder="玩家ID" clearable/>
      <!-- 靓号：    <el-input style="width:180px" :maxlength="10" v-model="pageQuery.superId" placeholder="玩家靓号" clearable/> -->
      帐号：  <el-input style="width:180px" placeholder="帐号" v-model="pageQuery.userName" clearable/>
      昵称：  <el-input style="width:180px" :maxlength="20" placeholder="玩家昵称" v-model="pageQuery.nickName" clearable/>
      <!-- 手机号：<el-input style="width:180px" type="phone" :maxlength="11" placeholder="手机号" v-model="pageQuery.phone" clearable/> -->
      <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
    </div>
    <div class="filter-container">
      <!-- <el-button type="primary" size="small" @click="handleSendGold">赠送身上金币</el-button> -->
      <el-button  v-if="hasPermission('B0102')" type="primary" size="small" @click="handleSendSafeGold">赠送安全金币</el-button>
      <!-- <el-button type="primary" size="small" @click="handleSetPhone">修改手机号</el-button> -->
      <!-- <el-button type="primary" size="small" @click="handleSetSuperId">设置靓号</el-button>
      <el-button type="primary" size="small" @click="handleUndoSuperId">取消靓号</el-button> -->
      <el-button  v-if="hasPermission('B0103')" type="primary" size="small" @click="handleBatchLock">批量冻结</el-button>
      <el-button  v-if="hasPermission('B0103')" type="primary" size="small" @click="handleActive">批量解禁</el-button>
    </div>

    <el-table :key='tableKey' :data="list" v-loading="listLoading"
              @selection-change="handleSelectChange" border fit highlight-current-row style="width: 100%">
      <el-table-column align="center" prop="playerId" type="selection" width="55" />
      <el-table-column align="center" prop="playerId" label="玩家ID" width="80" fixed/>
      <el-table-column align="center" prop="channelId" label="渠道ID" width="80" fixed>
        <template slot-scope="scope">
          <span >{{ getChannelName(scope.row.channelId)}}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column align="center" prop="superId" label="靓号ID" width="80"/>
      <el-table-column align="center" prop="userName" label="账号" width="160"/>-->
      <el-table-column align="center" prop="nickName" label="昵称" width="160"/>
      <!-- <el-table-column align="center" prop="phone" label="手机" width="120"/> -->
      <el-table-column align="center" prop="playerType" :formatter="formatterType" label="类型" width="80"/>
      <el-table-column align="center" prop="totalGold" label="总金币" width="107">
        <template slot-scope="scope">
          <span >{{scope.row.totalGold | goldToMoney}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="gold" label="游戏中金币" width="107">
        <template slot-scope="scope">
          <span >{{scope.row.gold | goldToMoney}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="safeGold" label="安全金币" width="107">
        <template slot-scope="scope">
          <span >{{scope.row.safeGold | goldToMoney}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="onlineState" label="游戏状态" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.onlineState === 0">离线</span>
          <span v-else>在线</span>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="state" label="玩家状态" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.state === 0">冻结</span>
          <span v-else>解禁</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="登录时间" width="154">
        <template slot-scope="scope">
          <span>{{scope.row.loginTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</span>
        </template>
      </el-table-column>
      <!--<el-table-column align="center" prop="loginIp" :formatter="formatIP" label="登录地区"/>-->
      <el-table-column align="center" prop="loginIp"  label="登录IP" width="214">
        <template slot-scope="scope">
          <div>{{scope.row.loginIp}}&nbsp&nbsp{{scope.row.ipsite}}{{formatIP(scope.row)}}</div>
          <div>
            <el-button v-if="scope.row.loginIp" size="mini"  type="info" @click="handleIpToLocationzzk(scope.row)">查看地址
            </el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" >
        <template slot-scope="scope">
          <el-button size="small"  type="danger" @click="handleDetailsToLocationzzk(scope.row)">查看
          </el-button>
          <el-button v-if="scope.row.state != 0" size="small"  type="warning" @click="handleBatchLockzzk(scope.row)">冻结
          </el-button>
          <el-button v-if="scope.row.state === 0" size="small"  type="primary" @click="handleActivezzk(scope.row)">解冻
          </el-button>
          <el-button size="small"  type="danger" @click="handleSendSafeGoldzzk(scope.row)">赠送金币
          </el-button>
          <el-button size="small"  type="primary" @click="handleGoldToLocationzzk(scope.row)">金币记录
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div v-show="!listLoading" class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="pageQuery.page"
                     :page-sizes="[10,20,30, 50]" :page-size="pageQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalSize">
      </el-pagination>
    </div>
    <!--金币赠送记录zzk-->
    <el-dialog  :title="GoldTitle" :visible.sync="GoldList" @close="GoldListClose"><div class="filter-container" >
      管理员ID：<el-input style="width:180px" :maxlength="10" v-model="pageQuery1.adminId" placeholder="管理员ID" clearable/>
      时间：    <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至"
                             start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions2" :clearable="false"></el-date-picker>
      <el-button type="primary" icon="el-icon-search" @click="handleSearchjb">搜索</el-button>
    </div>
      <el-table :data="Goldform" border fit highlight-current-row max-height="400" >
        <el-table-column align="center" prop="adminId" label="管理员ID" width="100" fixed/>
        <el-table-column align="center" prop="adminName" label="管理员名" width="100" fixed/>
        <el-table-column align="center" prop="channelId" label="渠道ID" width="100" fixed>
          <template slot-scope="scope">
            <span >{{ getChannelName(scope.row)}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="playerId" label="用户ID" width="90" fixed/>
        <!-- <el-table-column align="center" prop="superId" label="用户靓号" width="100" fixed/>
        <el-table-column align="center" prop="playerName" label="用户昵称" width="200" fixed/>-->
        <!-- <el-table-column align="center" prop="gold" label="赠送身上金币" width="200"/> -->
        <el-table-column align="center" prop="safeGold" label="赠送安全金币" width="160">
          <template slot-scope="scope">
            <span >{{scope.row.safeGold | goldToMoney}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="时间" >
          <template slot-scope="scope">
            <span>{{scope.row.time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</span>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-container">
        <el-pagination background @size-change="handleSizeChangejb" @current-change="handleCurrentChangejb" :current-page.sync="pageQuery1.page"
                       :page-sizes="[10,20,30, 50]" :page-size="pageQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalSizejb">
        </el-pagination>
      </div>
    </el-dialog>
    <!--IP列表界面zzk-->
    <el-dialog  :title="IPListTitle" :visible.sync="IPList" @close="IPListClose">
      <el-form label-width="80px" ref="IPList" >
      <div class="filter-container" >
        登录IP：  <el-input style="width:180px" :maxlength="20" v-model="IPListQuery.IP" placeholder="登录IP" clearable/>
        时间：    <el-date-picker v-model="IPTime" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions1" :clearable="false">
      </el-date-picker>
        <el-button type="primary" icon="el-icon-search" @click="handleIpToLocationzzk">搜索</el-button>
      </div>
      </el-form>
      <el-table :data="IPform" border fit highlight-current-row max-height="400" >
        <el-table-column align="center" prop="id" label="ID" width="70"/>
        <el-table-column align="center" prop="playername" label="用户昵称" width="200"/>
        <el-table-column align="center" prop="ip" label="登录IP" width="180"/>
        <el-table-column align="center" prop="ip"  label="登录城市" width="180">
          <template slot-scope="scope">
            <div>{{scope.row.ipsite}}{{formatIP(scope.row)}}</div>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="time" label="登录时间" width="200"/>
        <el-table-column align="center" prop="playerid" label="玩家ID"/>
      </el-table>
    </el-dialog>
    <!--查看界面zzk-->
    <el-dialog :title="DetailsTitle" class = "e-dialog1" :visible.sync="Details" @close="DetailsListClose">
      <el-scrollbar style="height:500px;">
        玩家信息<hr style="height:1px;border:none;border-top:1px solid #555555;" />
        <div class="el-table el-table--fit el-table--border el-table--fluid-height el-table--enable-row-hover el-table--enable-row-transition" style="max-height: 400px;margin-bottom: 60px;">
          <div class="el-table__body-wrapper is-scrolling-none" style="max-height: 352px;">
            <table cellspacing="0" cellpadding="0" border="0" class="el-table__body" style="width: 100%;">
              <colgroup>
                <col name="el-table_6_column_66" width="16">
                <col name="el-table_6_column_67" width="34">
                <col name="el-table_6_column_68" width="15">
                <col name="el-table_6_column_69" width="35">
              </colgroup>
              <tbody>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">玩家ID</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.playerId}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">渠道ID</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{getChannelName(Detailsform.channelId)}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">靓号ID</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.superId}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">昵称</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{Detailsform.nickName}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">类型</div></td>
                <!----><td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{formatterType(Detailsform.playerType)}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">手机</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{Detailsform.phone}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">账号</div></td>
                <td rowspan="1" colspan="3" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.userName}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">总金币</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.totalGold | goldToMoney}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">安全金币</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{Detailsform.safeGold | goldToMoney}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">游戏中金币</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.gold | goldToMoney}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">玩家状态</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell"><span v-if="Detailsform.onlineState === 0">离线</span><span v-else>在线</span></div></td>
              </tr>
              <!---->
              </tbody>
            </table><!----><!---->
          </div><!----><!----><!----><!---->
          <div class="el-table__column-resize-proxy" style="display: none;"></div>
        </div>
        平台信息<hr style="height:1px;border:none;border-top:1px solid #555555;" />
        <div class="el-table el-table--fit el-table--border el-table--fluid-height el-table--enable-row-hover el-table--enable-row-transition" style="max-height: 400px; margin-bottom: 40px;">
          <div class="el-table__body-wrapper is-scrolling-none" style="max-height: 352px;">
            <table cellspacing="0" cellpadding="0" border="0" class="el-table__body" style="width: 100%;">
              <colgroup>
                <col name="el-table_6_column_66" width="16">
                <col name="el-table_6_column_67" width="34">
                <col name="el-table_6_column_68" width="15">
                <col name="el-table_6_column_69" width="35">
              </colgroup>
              <tbody>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">注册IP</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.registerIp}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">注册时间</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{Detailsform.registerTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">登录IP</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.loginIp}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">登录时间</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{Detailsform.loginTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">登录次数</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.loginCount}}</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">退出时间</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{Detailsform.logoutTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">在线时长</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">{{Detailsform.onlinetime}}毫秒</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">游戏时间</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">{{Detailsform.gametime}}毫秒</div></td>
              </tr>
              <tr class="el-table__row">
                <td rowspan="1" colspan="1" class="el-table_6_column_66 is-center "><div class="cell jc">最后登录机器</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_67 is-center "><div class="cell">b34da90aee5426ffbb93eec429e69130</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_68 is-center "><div class="cell jc">用户注册机器</div></td>
                <td rowspan="1" colspan="1" class="el-table_6_column_69 is-center "><div class="cell">486c35c1d992f1e934fb348199894174</div></td>
              </tr>
              <!---->
              </tbody>
            </table><!----><!---->
          </div><!----><!----><!----><!---->
          <div class="el-table__column-resize-proxy" style="display: none;"></div>
        </div>
      </el-scrollbar>
    </el-dialog>
  </div>
</template>


<script>
  import axios from "axios";
  import qs from "qs";
  import {
    findIpList,
    findUserList,
    sendGold,
    sendSafeGold,
    setPhone,
    setSuperId,
    undoSuperId,
    batchLock,
    batchActive,
    locationDetail
  } from "@/api/user";

  import { getChannel } from "@/api/common";
  import { hasPermission } from "@/utils/auth"; // 验权
  import { parseTime, deepClone } from "@/utils";
  import { findGiftList } from "@/api/trans";

  export default {
    name: "userTable",
    data() {
      return {
        pickerOptions1: {
          disabledDate(time) {
            return time.getTime() > Date.now();
          },
        },
        timeRange: [new Date(), new Date()],
        pickerOptions2: {
          shortcuts: [
            {
              text: "最近一周",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit("pick", [start, end]);
              }
            },
            {
              text: "最近一个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                picker.$emit("pick", [start, end]);
              }
            },
            {
              text: "最近三个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                picker.$emit("pick", [start, end]);
              }
            }
          ]
        },
        IPTime:new Date(),
        time: new Date(),
        IPList:false,//IP列表
        IPListTitle:"",//IP弹窗Title
        //IPkey:1,
        //ip列表数据
        IPform:[],
        Details:false,//查看列表
        DetailsTitle:"",
        //查看列表数据
        Detailsform:{
          channelId: "",
          gold: 0,
          loginIp: "",
          loginTime: null,
          nickName: "",
          onlineState: null,
          phone: null,
          playerId: null,
          playerType: 1,
          safeGold: null,
          state: null,
          superId: null,
          totalGold: null,
          userName: "",
          registerTime:"",
          registerIp:"",
          loginCount:null,
          logoutTime:"",
          onlinetime:null,
          gametime:null
        },
        GoldList:false,//金币
        GoldTitle:"",//金币
        Goldform:[{
          adminId: 1,
          adminName: "admin",
          channelId: "111111",
          gold: 0,
          id: 2,
          playerId: 1005439,
          playerName: "游客1595229717148",
          safeGold: 100000,
          superId: 1005439,
          time: 1595666837000
        },{
          adminId: 1,
          adminName: "admin",
          channelId: "111111",
          gold: 0,
          id: 1,
          playerId: 1005439,
          playerName: "??1595229717148",
          safeGold: 999000,
          superId: 1005439,
          time: 1595229826000
        }],//金币
        tableKey: 0,
        list: null,
        listLoading: true,
        totalSize: 0,
        totalSizejb: 0,
        multipleSelection: [],
        channelMap: {},
        channels: [],
        typeOptions: [
          {
            value: "1",
            label: "玩家"
          },
          {
            value: "3",
            label: "机器人"
          }
        ],
        lockedOptions: [
          {
            value: "false",
            label: "解禁"
          },
          {
            value: "true",
            label: "冻结"
          }
        ],
        pageQuery: {
          page: 1,
          pageSize: 10,
          playerType: "1",
          playerId: undefined,
          superId: undefined,
          nickName: "",
          userName: "",
          phone: "",
          channelId: undefined,
          locked: undefined
        },
        pageQuery1: {
          page: 1,
          pageSize: 10,
          playerId: undefined,
          superId: undefined,
          adminId: undefined,
          startTime: undefined,
          endTime: undefined
        },
        IPListQuery: {
          IPTime: null,
          IP: null
        }
      };
    },
    created() {
      this.findChannelList();
    },
    methods: {
      hasPermission: hasPermission,
      formatterType(row, column) {
        let addrTxt = "玩家";
        return row.playerType == 3
          ? "机器人"
          : row.playerType == 2 ? "代理" : "玩家";
      },
      findListjb() {
        this.pageQuery1.startTime = this.timeRange[0].getTime();
        this.pageQuery1.endTime = this.timeRange[1].getTime();
        findGiftList(this.pageQuery1)
          .then(res => {
            this.Goldform = res.map.list;
            if (!this.Goldform) {
              this.Goldform = [];
            }

            this.totalSizejb = res.map.total;
            //this.listLoading = false;
          })
          .catch(() => {
            //this.listLoading = false;
          });
      },
      handleSizeChangejb(val) {
        this.pageQuery1.pageSize = val;
        this.findList();
      },
      handleCurrentChangejb(val) {
        this.pageQuery1.page = val;
        this.findList();
      },
      // 金币搜索
      handleSearchjb() {
        this.findListjb();
      },
      formatterTypeck(row) {
        let addrTxt = "玩家";
        return row == 3
          ? "机器人"
          : row == 2 ? "代理" : "玩家";
      },
      GoldListClose() {
        this.GoldList = false;
        //this.$refs["IPList"].resetFields();//重置表单
      },
      IPListClose() {
        this.IPList = false;
        this.$refs["IPList"].resetFields();//重置表单
      },
      DetailsListClose() {
        this.Details = false;
        //this.$refs["IPList"].resetFields();//重置表单
      },
      formatIP(row, column) {
        if(row.ipsite=="未知"){
        let addrTxt = "未知";
        var ippppp;
        if (row) {
          if (row.loginIp==null) {
            ippppp=row.ip;
          }else{
            ippppp=row.loginIp;
          }
          var res = locationDetail({ ip: ippppp })
            .then(res => {
              //console.log(res);
              //if (res.code == 200) {
                row.ipsite = res.map.location;
              //}
            })
            .catch(() => {
            });
        }
        }else{
          return;
        }
        //return addrTxt;
      },
      getChannelName(channelId) {
        let remark = "未知渠道";
        if (channelId) {
          let channel = this.channelMap[channelId];
          if (channel && channel.channelRemark) {
            remark = channel.channelRemark;
          }
        }
        return remark;
      },
      findChannelList() {
        getChannel()
          .then(res => {
            this.channels = res.map.list;
            console.log(this.channels);
            this.channelMap = {};
            if (this.channels && this.channels.length) {
              this.channels.forEach(element => {
                this.channelMap[element.channelId] = element;
              });
            }
            this.findList();
          })
          .catch(() => {
            this.findList();
          });
      },
      findList() {
        this.listLoading = true;
        /**/findUserList(this.pageQuery)
          .then(res => {
            this.list = res.map.list;
            this.totalSize = res.map.total;
            this.listLoading = false;
          })
          .catch(() => {
            this.listLoading = false;
          });
      },
      handleSizeChange(val) {
        this.pageQuery.pageSize = val;
        this.findList();
      },
      handleCurrentChange(val) {
        this.pageQuery.page = val;
        this.findList();
      },
      // 搜索
      handleSearch() {
        this.pageQuery.page = 1;
        this.findList();
      },
      // 复选框事件
      handleSelectChange(val) {
        if (val && val.length > 0) {
          this.multipleSelection = [];
          for (let i = 0; i < val.length; i++) {
            this.multipleSelection.push(val[i]);
          }
        } else {
          this.multipleSelection = [];
        }
      },
      // 赠送身上金币
      handleSendGold() {
        if (this._limitSelections(1, true)) {
          this.$prompt("请输入赠送金币", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            inputPattern: /^-?[0-9]*.?[0-9]*$/,
            inputErrorMessage: "请输入整数"
          })
            .then(({ value }) => {
              this.listLoading = true;
              sendGold(this.multipleSelection[0].playerId, value)
                .then(res => {
                  this.$message({
                    message: "赠送成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 赠送保险箱金币
      handleSendSafeGold() {
        if (this._limitSelections(1, true)) {
          this.$prompt("请输入赠送金币", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            inputPattern: /^-?[0-9]*.?[0-9]*$/,
            inputErrorMessage: "请输入整数"
          })
            .then(({ value }) => {
              this.listLoading = true;
              sendSafeGold(this.multipleSelection[0].playerId, value * 1000)
                .then(res => {
                  this.$message({
                    message: "赠送成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 赠送保险箱金币zzk单个赠送
      handleSendSafeGoldzzk(row) {
        if (1==1) {
          this.$prompt("请输入赠送金币", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            inputPattern: /^-?[0-9]*.?[0-9]*$/,
            inputErrorMessage: "请输入整数"
          })
            .then(({ value }) => {
              this.listLoading = true;
              sendSafeGold(row.playerId, value * 1000)
                .then(res => {
                  this.$message({
                    message: "赠送成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      handleSetPhone() {
        if (this._limitSelections(1, true)) {
          this.$prompt("请输入手机号", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            inputPattern: /^(1[3-9][0-9])\d{8}$/,
            inputErrorMessage: "请输入正确手机号"
          })
            .then(({ value }) => {
              setPhone(this.multipleSelection[0].playerId, value)
                .then(res => {
                  this.$message({
                    message: "设置成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 设置靓号
      handleSetSuperId() {
        if (this._limitSelections(1, true)) {
          this.$prompt("请输入靓号", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            inputPattern: /^[1-9]\d{5}$/,
            inputErrorMessage: "请输入6位正整数",
            maxlength: 6
          })
            .then(({ value }) => {
              setSuperId(this.multipleSelection[0].playerId, value)
                .then(res => {
                  this.$message({
                    message: "设置成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 取消靓号
      handleUndoSuperId() {
        if (this._limitSelections(1, true)) {
          this.$confirm("确定要取消该代理靓号吗？", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          })
            .then(({ value }) => {
              undoSuperId(this.multipleSelection[0].playerId)
                .then(res => {
                  this.$message({
                    message: "修改成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 批量锁定
      handleBatchLock() {
        if (this._limitSelections(1, false)) {
          for (let index = 0; index < this.multipleSelection.length; index++) {
            let element = this.multipleSelection[index];
            if (element.state != 1) {
              this.$message({
                message: "选择中的玩家包含已解禁玩家，请重新选择",
                type: "error"
              });
              return false;
            }
          }
          this.$confirm(
            "你确定要冻结 " + this.multipleSelection.length + " 个玩家吗？",
            "提示",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }
          )
            .then(() => {
              let ids = [];
              this.multipleSelection.forEach(element => {
                ids.push(element.playerId);
              });
              batchLock(ids)
                .then(res => {
                  this.$message({
                    message: "冻结成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 单个锁定
      handleBatchLockzzk(row) {
        if (1==1) {
          this.$confirm(
            "你确定要冻结 1 个玩家吗？",
            "提示",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }
          )
            .then(() => {
              let ids = [];
              ids.push(row.playerId);
              batchLock(ids)
                .then(res => {
                  this.$message({
                    message: "冻结成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      handleIpToLocation(row) {
        this.listLoading = true;
        if (row.loginIp) {
          locationDetail({ ip: row.loginIp })
            .then(res => {
              let location = "未知";
              if (res.code == 200) {
                location = res.map.location;
              }
              this.listLoading = false;
              this.$alert(location, "地址", {
                confirmButtonText: "确定"
              });
            })
            .catch(() => {
              this.listLoading = false;
              this.$alert("未知", "地址", {
                confirmButtonText: "确定"
              });
            });
        }
      },
      //金币记录列表
      handleGoldToLocationzzk(row) {
        this.GoldList = true;
        this.GoldTitle = "金币赠送记录";
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
        console.log(start);
        this.timeRange[0] = start;
        this.pageQuery1.page = 1;
        this.findListjb();
        //this.IPform = deepClone(row);
      },
      //IP列表
      handleIpToLocationzzk(row) {
        this.IPList = true;
        this.IPListTitle = "会员登录IP查询";
        this.IPListQuery.IPTime=this.getyyyyMMdd(this.IPTime);
        console.log(this.IPListQuery);
        /**/findIpList(this.IPListQuery)
          .then(res => {
            this.IPform = res.map.list;
            this.totalSize = res.map.total;
            this.listLoading = false;
          })
          .catch(() => {
            this.listLoading = false;
          });
        //this.IPform = deepClone(row);
      },
      getyyyyMMdd(d){
        var curr_date = d.getDate();
        var curr_month = d.getMonth() + 1;
        var curr_year = d.getFullYear();
        String(curr_month).length < 2 ? (curr_month = "0" + curr_month): curr_month;
        String(curr_date).length < 2 ? (curr_date = "0" + curr_date): curr_date;
        var yyyyMMdd = curr_year + "" + curr_month +""+ curr_date;
        return yyyyMMdd;
      },
  //查看列表
      handleDetailsToLocationzzk(row) {
        this.Details = true;
        this.DetailsTitle = "查看详情列表";
        this.Detailsform = deepClone(row);
        console.log(this.Detailsform);
      },
      // 解禁单个玩家
      handleActivezzk(row) {
        if (1==1) {
          this.$confirm(
            "你确定要解禁 1 个玩家吗？",
            "提示",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }
          )
            .then(() => {
              let ids = [];
              ids.push(row.playerId);
              batchActive(ids)
                .then(res => {
                  this.$message({
                    message: "解禁成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 解禁多个玩家
      handleActive() {
        if (this._limitSelections(1, false)) {
          for (let index = 0; index < this.multipleSelection.length; index++) {
            let element = this.multipleSelection[index];
            if (element.state != 0) {
              this.$message({
                message: "选择中的玩家包含已解禁玩家，请重新选择",
                type: "error"
              });
              return false;
            }
          }

          this.$confirm(
            "你确定要解禁 " + this.multipleSelection.length + " 个玩家吗？",
            "提示",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }
          )
            .then(() => {
              let ids = [];
              this.multipleSelection.forEach(element => {
                ids.push(element.playerId);
              });
              batchActive(ids)
                .then(res => {
                  this.$message({
                    message: "解禁成功",
                    type: "success"
                  });
                  this.findList();
                })
                .catch(() => {
                  this.listLoading = false;
                });
            })
            .catch(() => {});
        }
      },
      // 提示框
      _limitSelections(limit, isLimit) {
        let length = this.multipleSelection.length;
        if (!isLimit) {
          if (length < limit) {
            this.$message({
              message: "请至少选择" + limit + "位玩家"
            });
            return false;
          }
          return true;
        }

        if (length > limit) {
          this.$message({
            message: "只能选择" + limit + "位玩家"
          });
          return false;
        }
        if (length < limit) {
          this.$message({
            message: "请选择" + limit + "位玩家"
          });
          return false;
        }
        return true;
      }
    }
  };
</script>
